package app.sys.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import app.sys.data.entity.Menu;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MenuMapper extends BaseMapper<Menu> {

    @Select("select m.*" +
            " from" +
            " sys_user u" +
            " inner join sys_user_role us on u.id = us.user_id" +
            " inner join sys_role_menu rm on us.role_id = rm.role_id" +
            " inner join sys_menu m on m.id= rm.menu_id" +
            " where u.id =#{userId} and u.del_flag =0 and" +
            " u.is_active =0 and  us.del_flag =0" +
            " and  rm.del_flag =0" +
            " and  m.del_flag =0"+
            " and  m.del_flag =0")
    public List<Menu> getMenusByUser(@Param("userId") Long userId);
}
